package com.zhanggm.springcloud.jpa.entity;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;

import java.io.Serializable;
import java.util.List;

import javax.persistence.*;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonFormat;

/**
 * @author zhanggm
 * 学生表
 */
@Data
//@JsonInclude(JsonInclude.Include.ALWAYS)
@Entity
@Table(name = "stu_student")
@DynamicInsert
@DynamicUpdate
public class StuStudent extends BaseEntity implements Serializable {

	/**
	 * 主键
	 */
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "id")
	private Integer id;

	/**
	 * 姓名
	 */
	@Column(name = "name")
	private String name;

	/**
	 * 头像地址
	 */
	@Column(name = "head_img")
	private String headImg;

	/**
	 * 班级Id
	 */
	@Column(name = "classes_id")
	private Integer classesId;

	@Transient
	private List<Integer> classesIdList;

	/*@OneToOne
	@JoinColumn(name = "classes_id",referencedColumnName = "id",insertable = false,updatable = false)
	private StuClasses stuClasses;*/

	@JsonIgnoreProperties("stuStudents")
	@ManyToOne
	@JoinColumn(name = "classes_id",insertable = false,updatable = false)
	private StuClasses stuClasses;

	@Transient
	private String classesName;

	/**
	 * 省Id
	 */
	@Column(name = "provice_id")
	private Integer proviceId;

//	@ManyToOne
//	@JoinColumn(name = "provice_id",insertable = false,updatable = false)
//	private StuArea provice;

	/**
	 * 市Id
	 */
	@Column(name = "city_id")
	private Integer cityId;

//	@ManyToOne
//	@JoinColumn(name = "city_id",insertable = false,updatable = false)
//	private StuArea city;

	/**
	 * 区Id
	 */
	@Column(name = "area_id")
	private Integer areaId;

//	@ManyToOne
//	@JoinColumn(name = "area_id",insertable = false,updatable = false)
//	private StuArea area;

	/**
	 * 入学时间
	 */
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@Column(name = "join_time")
	private java.util.Date joinTime;

	/**
	 * 性别
	 */
	@Column(name = "gender")
	private Integer gender;


	@ManyToMany(cascade = {CascadeType.REFRESH})
	@JoinTable(name = "stu_student_hobby_relation",joinColumns = @JoinColumn(name = "stu_id"),inverseJoinColumns = @JoinColumn(name = "hobby_id"))
	private List<StuHobby> hobbyList;

	@Transient
	private String hobbyName;


}
